package org.example;

import java.util.Scanner;

public class calapp {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("Enter the first number: ");
            double a = scanner.nextDouble();
            System.out.println("Enter the operation: ");
            String operation = scanner.next();
            System.out.println("Enter the second number: ");
            double b = scanner.nextDouble();

            double result = 0;
            switch (operation){
                case "+":
                    result = a + b;
                    break;
                case "-":
                    result = a - b;
                    break;
                case "*":
                    result = a * b;
                    break;
                case "/":
                    if (b == 0){
                        System.out.println("Cannot divide by zero");
                        continue;
                    }
                    result = a / b;
                    break;
                default:
                    System.out.println("Invalid operation");
                    continue;
            }
            System.out.println("Result: " + result);
            System.out.println("Do you want to continue? (y/n)");
            String cont = scanner.next();
            if (cont.equals("n")){
                break;
            }
        }
    }
}
